import 'package:hj_crm/utils/internet_cubit.dart';
import 'package:hj_crm/utils/event_bus.dart';

class NetworkCubit {
  static EventBus? eventBus = EventBus();
  static InternetCubit? cubit;

  static void networkCheck() {
    cubit = InternetCubit()..addListener((value) => eventBus?.fire(value));
  }

  static networkListener<T>(Function(T) onData) {
    eventBus?.on<T>().listen((event) => onData(event));
  }

  static distroy() {
    eventBus?.destroy();
    eventBus = null;
    cubit?.dispose();
    cubit = null;
  }
}
